
title = "淘宝验号"
version = "2.8.3"


def run(pid=None):
    import os
    from tkinter.messagebox import showerror
    from taobao_check.tools import get_proc_memory, kill_process

    try:
        if pid:
            my_pid = [os.getpid(), pid]
            print("pid:", my_pid)
            print(get_proc_memory("taobao_check.exe"))
            for pid in get_proc_memory("taobao_check.exe"):
                if pid not in my_pid:
                    print("kill pid:", pid)
                    kill_process(pid)

        from taobao_check.ui import UI
        taobao = UI(title, version)
    except Exception as e:
        showerror(title='错误', message=f'程序启动错误: {e}')
    else:
        try:
            taobao.mainloop()
        except Exception as e:
            showerror(title='错误', message=f'程序运行错误: {e}')
